package org.opens.listener;

import lombok.extern.slf4j.Slf4j;
import org.opens.event.StudentEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class StudentListener {
    /**
     * 监听对应的事件对象.
     * 注解@EventListener就是用来表述监听的意思的, condition执行监听业务方法的前提条件
     * @param studentEvent  被监听的事件对象
     */
    @EventListener(condition = "#studentEvent.name != null")
    @Async
    public void handEvent(StudentEvent studentEvent) {
        log.info("接受到事件对象:" + studentEvent);
    }


}
